/*
 * @Author: TC (tengchao@taqu.cn)
 * @Date: 2025-10-09 19:54:02
 * @Last Modified by: TC (tengchao@taqu.cn)
 * @Last Modified time: 2025-10-10 11:37:50
 */

import { app } from "db://assets/FrameWork/App";
import { EMoleConfigConst } from "../Const/MoleConfigConst";

/**
 * 关卡配置
 */
export namespace nsMoleMissionCfg {
    /**
     * 获取关卡配置
     * @param missionId
     * @returns
     */
    export function getMissionCfg(missionId: number): IMoleCfgInterface.IMission {
        const cfg = app.cfgMgr.getCfgByKey(EMoleConfigConst.Mission, "mission", missionId);
        if (!cfg) {
            app.log.error(`未找到关卡配置: ${missionId}`);
            return null;
        }
        return cfg;
    }

    /**
     * 获取最大关卡ID
     * @returns
     */
    export function getMaxMissionId(): number {
        const cfgs = app.cfgMgr.getCfg(EMoleConfigConst.Mission);
        return cfgs?.length > 0 ? cfgs[cfgs.length - 1].mission : 1;
    }
}
